package com.feicheng.controller.system;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.common.exception.SystemException;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Client;
import com.feicheng.service.IFClientService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuxiuwen
 * @since 2022-02-16
 */
@RestController
@RequestMapping("/admin/client")
public class ClientController {
	
	@Autowired
	IFClientService clientService;
	

	@GetMapping("/info")
	public ResultInfo getClient(Integer clientId) {
			
		
			//如果获取的client表主键client_id为空
			//则抛出SystemException异常
			if (null == clientId) {
				throw new SystemException("分类主键缺失");
			}
			
			
			
			//返回获取的client表中的详情信息
			return clientService.getClient(clientId);
		}
	
	//查询客户分页信息
	@GetMapping("/page")
	public ResultInfo getClientByPage(
			Client client, 
			@RequestParam(defaultValue="1") Integer current, 
			@RequestParam(defaultValue="10")Integer size) {
		
		
		//根据得到的Client类、开始数据下标和每页展示数据的数量
		//获取指定页数的数据
		return clientService.getClientByPage(client, current, size);
		
	}
	

}
